function index = mfindstr(string, varargin);

% MFINDSTR - find multiple patterns in a single string
%
%    INDEX = MFINDSTR(STRING, P1, P2, ...) finds occurrences of all
%    the patterns P1, P2, ... in the string STRING.  INDEX contains
%    the starting index within STRING where the patterns are found.

% By:   S.C. Molitor (smolitor@med.unc.edu)
% Date: March 1, 2000

% initialize output to prevent MATLAB errors

index = [];

% check input parameters

if (nargin < 2)
   msgbox('Insufficient number of arguments', 'MFINDSTR Error', 'warn');
   return
elseif (~ischar(string) | isempty(string))
   msgbox('STRING must be a character string', 'MFINDSTR Error', 'warn');
   return
end

% loop through patterns to find matches
% return sorted index list

for i = 1 : length(varargin)
   if (ischar(varargin{i}))
      index = [index findstr(string, varargin{i})];
   end
end
index = sort(index);
return
